package com.hundsun.yr.universal.p2p.bean.enums;

import java.util.ArrayList;
import java.util.HashMap;

import android.text.TextUtils;

import com.hundsun.yr.universal.p2p.bean.UserPersonalInfo;
import com.hundsun.yr.universal.p2p.bean.enums.base.Enum;
import com.hundsun.yr.universal.p2p.bean.enums.base.LabelEnum;
/**
 * 房屋状况枚举类
 * @author tonglj
 *
 */
public class HousePropertyEnum  extends LabelEnum{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	
	public static HousePropertyEnum YES = new HousePropertyEnum("YES", "有");
	public static HousePropertyEnum NO = new HousePropertyEnum("NO", "无");
	
	private static HashMap<String,String> mHashMap = new HashMap<String,String>();
	
	protected HousePropertyEnum(String name, String lable) {
		super(name, lable, UserPersonalInfo.HOUSEPROPERTY);
		title = "房产";
	}
	
	@SuppressWarnings("unchecked")
	public static ArrayList<LabelEnum> getList() {
		mList.clear();
		mList.addAll(Enum.getEnumList(HousePropertyEnum.class));
		return mList;
	}
	
	public static HashMap<String,String> getHashMap(){
		if(mHashMap==null || mHashMap.size()==0){ //保证mHashMap只进行一次赋值，只遍历一次mList
			ArrayList<LabelEnum> list = getList();
			for(LabelEnum labelEnum : list){
				mHashMap.put(labelEnum.getName(), labelEnum.getLable());
			}
		}
		return mHashMap;
	}
	
	/**
	 * 根据name获取枚举类中的lable
	 * @param lableClass
	 * @param name
	 * @return
	 */
	public static String getLable(Class<?extends LabelEnum> lableClass,String name ){
		ArrayList<LabelEnum> list = getList();
		for (LabelEnum labelEnum : list) {
			if(TextUtils.equals(labelEnum.getName(), name)){
				return labelEnum.getLable();
			}
		}
		return "";
	}
}
